diff --git a/sympy/core/mod.py b/sympy/core/mod.py
index eae25630cc..bd5f2acc0c 100644
--- a/sympy/core/mod.py
+++ b/sympy/core/mod.py
@@ -124,20 +124,24 @@ def doit(p, q):
                 both_l[isinstance(arg, cls)].append(arg)
 
             if mod_l and all(inner.args[1] == q for inner in mod_l):
-                # finding distributive term
+                was = non_mod_l[:]
                 non_mod_l = [cls(x, q) for x in non_mod_l]
-                mod = []
-                non_mod = []
-                for j in non_mod_l:
-                    if isinstance(j, cls):
-                        mod.append(j.args[0])
-                    else:
-                        non_mod.append(j)
-                prod_mod = Mul(*mod)
-                prod_non_mod = Mul(*non_mod)
-                prod_mod1 = Mul(*[i.args[0] for i in mod_l])
-                net = prod_mod1*prod_mod
-                return prod_non_mod*cls(net, q)
+                changed = was != non_mod_l
+                if changed or mod_l and all(inner.args[1] == q for inner in mod_l):
+                    # finding distributive term
+                    non_mod_l = [cls(x, q) for x in non_mod_l]
+                    mod = []
+                    non_mod = []
+                    for j in non_mod_l:
+                        if isinstance(j, cls):
+                            mod.append(j.args[0])
+                        else:
+                            non_mod.append(j)
+                    prod_mod = Mul(*mod)
+                    prod_non_mod = Mul(*non_mod)
+                    prod_mod1 = Mul(*[i.args[0] for i in mod_l])
+                    net = prod_mod1*prod_mod
+                    return prod_non_mod*cls(net, q)
 
         # XXX other possibilities?
 
